import server from '../utility/serve'
export default (url,data={},method='GET')=>{
  return new Promise((resolve,reject)=>{
    wx.request({
      url:server.host+url,
      data,
      method,
      header:{
        cookie:wx.getStorageSync('cookies')[2]
      },
      success: (res) => {
        if(data.loginInfor){
          wx.setStorage({
            key:'cookies', 
            data:res.cookies
          })
        };
        console.log('success', res)
        resolve(res.data)
      },
      fail:(err)=> {
        console.log('fail', err)
        reject(err)
      }
    })
  })
}